﻿using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.DependencyInjection;

namespace Xms.Abp.BackgroundJob;

[Dependency(TryRegister = true)]
public class NullBackgroundScheduleManager: IBackgroundScheduleManager, ISingletonDependency
{
    public Task<Guid> EnqueueAsync(
        Guid busId,
        string jobName,
        string displayName,
        object args,
        string cron,
        bool isEnabled,
        Guid? tenantId,
        BackgroundJobPriority priority = BackgroundJobPriority.Normal,
        int? timeout = null,
        short? maxTryCount = null,
        IEnumerable<int> retryIntervals = null,
        CancellationToken stoppingToken = default)
    {
        throw new AbpException("Background schedule system has not a real implementation. If it's mandatory, use an implementation (either the default provider or a 3rd party implementation). If it's optional, check IBackgroundScheduleManager.IsAvailable() extension method and act based on it.");
    }

    public Task DeleteAsync(
        Guid busId,
        string jobName,
        CancellationToken stoppingToken = default)
    {
        throw new AbpException("Background schedule system has not a real implementation. If it's mandatory, use an implementation (either the default provider or a 3rd party implementation). If it's optional, check IBackgroundScheduleManager.IsAvailable() extension method and act based on it.");
    }

    public Task DeleteAsync(
        Guid id,
        CancellationToken stoppingToken = default)
    {
        throw new AbpException("Background schedule system has not a real implementation. If it's mandatory, use an implementation (either the default provider or a 3rd party implementation). If it's optional, check IBackgroundScheduleManager.IsAvailable() extension method and act based on it.");
    }

    public bool IsAvailable()
    {
        return false;
    }

    public Task UpdateAsync(Guid id, object args, string cron, bool isEnabled, CancellationToken stoppingToken = default)
    {
        throw new AbpException("Background schedule system has not a real implementation. If it's mandatory, use an implementation (either the default provider or a 3rd party implementation). If it's optional, check IBackgroundScheduleManager.IsAvailable() extension method and act based on it.");
    }
}
